import React from 'react';
import FileUpload from './react-fileupload.jsx'

class FileUploader extends React.Component {
    render() {	
	let options={
        baseUrl:'/manage/product/upload.do',
        fileFieldName : 'upload_file',
        chooseAndUpload : true,//选择后自动上传，不用再点击upload的按钮
        dataType: 'json',
        uploadSuccess : (res) => this.props.onSuccess(res.data),
        uploadError :(res) =>  this.props.onError(res.message || '上传图片出错了')
	}
	return (
		<FileUpload options={options}>
			<button className='btn btn-xs btn-default' ref="chooseAndUpload">请选择图片</button>
			{/* chooseAndUpload为true时，这个button 就不需要了<button ref="uploadBtn">upload</button> */}
		</FileUpload>
	)	        
    }
}

export default FileUploader;

